package Week5.J0515;

import java.util.Arrays;
import java.util.PriorityQueue;

public class 主持人调度二_xv {
    public int minmumNumberOfHost (int n, int[][] startEnd) {
        Arrays.sort(startEnd, (a, b)->{
            return a[0] <= b[0] ? -1 : 1;
        });

        PriorityQueue<Integer> heap = new PriorityQueue<>();
        heap.offer(startEnd[0][1]);

        for (int i = 1; i < n; i++) {
            int a = startEnd[i][0], b = startEnd[i][1];
            if (a >= heap.peek()) {
                heap.poll();
            }
            heap.offer(b);
        }
        return heap.size();
    }
}
